﻿<template>
  <div>
    <!--查询参数-->
    <params ref="params" @handleRefresh="handleRefresh" :loading="loading"></params>
    <!--表格页面-->
    <my-table ref="myTable" :columns="columns" :loading="loading" title="分销员申请列表" :dataSource="dataSource" @loadData="loadData" @handleExport="handleExport" @handleDetail="handleDetail" exportAction="saleApplyFor_export" detailAction="saleApplyFor_details" />
    <detail v-if="modifyEntity.showDetail" @handleRefresh="handleRefresh" :modifyEntity="modifyEntity" />
  </div>
</template>
<script>
import detail from './detail'
import myTable from '_c/myTable/index'
import params from './components/params'
import { saleapplyforColumns, querySaleapplyforPage, deleteSaleapplyfor } from './saleapplyfor'

export default {
  name: 'Saleapplyfor',
  components: { params, detail, myTable },
  data() {
    return {
      modifyEntity: {
        // 传递的主键
        id: '',
        // 页面操作类型
        operation: '',
        // 是否展示编辑页面
        showModify: false,
        // 是否展示详情页面
        showDetail: false,
      },
      // 加载动画
      loading: false,
      // 绑定的数据源
      dataSource: [],
      // 表格绑定的列
      columns: saleapplyforColumns,
    }
  },
  mounted() {
    this.loadData()
  },
  methods: {
    //#region 查询列表
    // 保存/修改后刷新表格
    handleRefresh() {
      this.modifyEntity.showDetail = false
      this.modifyEntity.showModify = false
      this.$refs.myTable.pagination.current = 1
      this.loadData()
    },
    // 加载数据
    loadData() {
      this.loading = true
      let that = this
      let queryParams = {
        ...this.$refs.params.params,
        current: this.$refs.myTable.pagination.current,
        pageSize: this.$refs.myTable.pagination.pageSize,
      }
      querySaleapplyforPage(queryParams)
        .then((res) => {
          let { data, totalCount } = res.data
          that.dataSource = data
          this.$refs.myTable.pagination.total = totalCount
          that.loading = false
        })
        .catch(() => {
          that.loading = false
        })
    },
    //#endregion



    //#region 详情
    // 打开详情页面
    handleDetail(item) {
      this.modifyEntity = {
        id: item.id,
        showDetail: true,
        showModify: false,
        operation: this.operationFlag.Detail,
      }
    },
    //#endregion

    //#region 导入
    // 导入数据
    handleImport() { },
    //#endregion

    //#region 导出
    // 导出数据
    handleExport() { },
    //#endregion
  },
}
</script>
